package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.StrategyComment;
import cn.wolfcode.wolf2w.query.StrategyCommentQuery;
import cn.wolfcode.wolf2w.service.IStrategyCatalogService;
import cn.wolfcode.wolf2w.service.IStrategyCommentService;
import cn.wolfcode.wolf2w.service.IStrategyThemeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;


/**
 * Created by 甘静斌 on 2020-08-11 19:11
 */
@Controller
@RequestMapping("strategyCommend")
public class StrategyCommentController {

    @Autowired
    private IStrategyCommentService strategyCommentService;

    @Autowired
    private IStrategyThemeService strategyThemeService;

    @Autowired
    private IStrategyCatalogService catalogService;

    /**
     * 查询所有列表和分页操作
     * @param model
     * @param qo
     * @return
     */
    @RequestMapping("/list")
    public Object list(Model model, @ModelAttribute("qo") StrategyCommentQuery qo){

        Page<StrategyComment> page = strategyCommentService.query(qo);
        model.addAttribute("page",page );
        return "/strategyCommend/list";
    }

   /* *//**
     * 后端攻略明细添加和编辑功能
     * @param model
     * @param id
     * @return
     *//*
    @RequestMapping("/input")
    public Object input(Model model,String id){

       //strategyComment  编辑操作回显
       // model.addAttribute("strategyComment", strategyCommentService.getId(id));
        //catalogs  分类下拉框显示分组数据
        model.addAttribute("catalogs",catalogService.queryGroupList());
        //themes  主题下拉框列表
       model.addAttribute("themes", strategyCommentService.list());

        return "/strategyComment/input";
    }*/

  /*  *//**
     * input页面保存操作
     * @param strategyComment
     * @return
     *//*
    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(StrategyComment strategyComment){

        //input页面保存操作
        strategyCommentService.saveOrUpdate(strategyComment);
        return JsonResult.success();
    }

    //攻略明细删除操作
    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(String id){


        strategyCommentService.delete(id);
        return JsonResult.success();
    }

    //changeState
    //攻略明细下架操作
    @RequestMapping("/changeState")
    @ResponseBody
    public Object changeState(String id,int state){


        strategyCommentService.changeState(id,state);
        return JsonResult.success();
    }*/

}
